package com.runen.infinitemovement.model.api;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Create by LiaoDuanHong
 * Create on ${date}
 */
public class WeatherAPI {
    private static String EorrInf = "";

    /**
     * get请求
     *
     * @param url 地址
     */
    public static String LoadData(String url) {
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10, TimeUnit.SECONDS)
                .readTimeout(20, TimeUnit.SECONDS)
                .build();

        Request request = new Request.Builder().url(url).build();

        Call call = okHttpClient.newCall(request);
        Response execute = null;
        String str = "";
        try {
            execute = call.execute();
            str = execute.body().string();
        } catch (IOException e) {
            EorrInf = e.toString();
            e.printStackTrace();
        }
        return str;
    }
}
